{extend name="public:adminbase" /}
{block name="content"}


<div class="container-fluid p-t-15">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">

        <div class="tab-content">
          <div class="tab-pane active">

            <form onsubmit="return false;" method="post" name="edit-form" class="form-horizontal">

              <div class="form-group">
                <label class="btn-block " >邮件服务器配置
                  <br>
                  <code>目前只支持阿里云企业邮箱，且需要开启https通道。地址：https://qiye.aliyun.com，教程：https://micuer.com/new/1082.html</code>
                </label>
              </div>

              <div class="form-group">
                <label class="col-md-3 control-label">邮件服务器SMTP地址</label>
                <div class="col-md-7">
                  <input class="form-control "
                         type="text"
                         name="smtp_address"
                         value="{:config('email.smtp_address','smtp.mxhichina.com')}"
                         placeholder="请输入邮件服务器SMTP地址" >
                  <small class="help-block">调用方式：<code>config('email.smtp_address')</code>，阿里邮箱填写：smtp.mxhichina.com</small>
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-3 control-label">邮件服务器SMTP端口</label>
                <div class="col-md-7">
                <input class="form-control"
                       type="text"
                       name="smtp_port"
                       value="{:config('email.smtp_port')}"
                       placeholder="请输入邮件服务器SMTP端口" >
                <small class="help-block">调用方式：<code>config('email.smtp_port',587)</code>,常用端口有465，587，25，如果发送是被可尝试更换端口</small>
                </div>
              </div>

              <div class="form-group">
                <label class="col-md-3 control-label">邮件服务器encryption</label>
                <div class="col-md-7">
                <input class="form-control"
                       type="text"
                       name="encryption"
                       value="{:config('email.encryption','ssl')}"
                       placeholder="不懂的不要乱改" >
                <small class="help-block">调用方式：<code>config('email.encryption')</code></small>
                </div>
              </div>

              <div class="form-group">
                <label class="col-md-3 control-label">用户名</label>
                <div class="col-md-7">
                <input class="form-control"
                       type="text"
                       name="username"
                       value="{:config('email.username')}"
                       placeholder="请输入用户名" >
                <small class="help-block">调用方式：<code>config('email.username')</code></small>
                </div>
              </div>

              <div class="form-group">
                <label class="col-md-3 control-label">称谓</label>
                <div class="col-md-7">
                <input class="form-control"
                       type="text"
                       name="name"
                       value="{:config('email.name')}"
                       placeholder="请输入" >
                <small class="help-block">调用方式：<code>config('email.name')</code>,邮件发送者对外显示的昵称如：米醋儿网邮件客服</small>
                </div>
              </div>

              <div class="form-group">
                <label class="col-md-3 control-label" >密码</label>
                <div class="col-md-7">
                <input class="form-control"
                       type="text"
                       name="password"
                       value="{:config('email.password')}"
                       placeholder="请输入用户名" >
                <small class="help-block">调用方式：<code>config('email.password')</code>，授权密码或者是独立密码，阿里云邮箱为登录密码</small>
                </div>
              </div>



              <div class="form-group">
                <label class="col-md-3 control-label" >测试邮件地址</label>
                <div class="col-md-7">
                <input class="form-control"
                       type="text"
                       name="testMailAddress"
                       id="testMailAddress"
                       value="{:config('email.testMailAddress')}"
                       placeholder="请输入测试邮件地址" >
                <small class="help-block">
                  <button class="btn btn-sm btn-primary" onclick="sendTestEmail()">发送测试邮件</button>
                </small>
                </div>
              </div>



              <div class="form-group">
                <div class="col-md-3"> &nbsp;</div>
                <div class="col-md-7">
                <button type="submit" onclick="formsub()" class="btn btn-primary m-r-5">保存配置</button>
                <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
                </div>
              </div>
            </form>

          </div>
        </div>

      </div>
    </div>

  </div>

</div>
{include file="public/afooter"}
<script>

  function formsub() {
    var data = $("form").serialize();
    var url = "{:url('save')}"
    $.post(url,data,function (e) {
      if(e.code != 200){
        error(e.msg);
      }else {
        success(e.msg);
        setTimeout(location.reload(), 1000);

      }
    })
  }

  //发送测试邮件
  function sendTestEmail() {
      var email = $("#testMailAddress").val();
      var data = {
          email:email
      }
      var url = "{:url('test')}"
      $.post(url,data,function (e) {
          if(e.code != 200){
              error(e.msg);
          }else {
              success(e.msg);
          }
      })
  }

</script>
{/block}